'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var checkRegisterParam = function () {
  var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(ctx, next) {
    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            (0, _common.checkParam)(ctx, {
              //字母开头接普通字符4-9位
              nick: /^[A-Za-z]\w{4,9}$/,
              //不匹配全数字，不匹配全字母，6-10位
              pwd: /(?!^[0-9]+$)(?!^[A-Za-z]+$)^.{6,10}$/
            });
            return _context.abrupt('return', next().then(function () {
              ctx.body['paramchecked'] = 1;
            }));

          case 2:
          case 'end':
            return _context.stop();
        }
      }
    }, _callee, this);
  }));

  return function checkRegisterParam(_x, _x2) {
    return _ref.apply(this, arguments);
  };
}();

var _koaRouter = require('koa-router');

var _koaRouter2 = _interopRequireDefault(_koaRouter);

var _common = require('../Util/common');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { return step("next", value); }, function (err) { return step("throw", err); }); } } return step("next"); }); }; }

var userRouter = new _koaRouter2.default();

userRouter.post('/login', function () {
  var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(ctx) {
    return regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            console.log(ctx.request.url);

          case 1:
          case 'end':
            return _context2.stop();
        }
      }
    }, _callee2, undefined);
  }));

  return function (_x3) {
    return _ref2.apply(this, arguments);
  };
}());

userRouter.post('/register', checkRegisterParam, function () {
  var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(ctx) {
    return regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
          case 'end':
            return _context3.stop();
        }
      }
    }, _callee3, undefined);
  }));

  return function (_x4) {
    return _ref3.apply(this, arguments);
  };
}());

exports.default = userRouter;